package dao.daoImpl;

import dao.DepartInfoDao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import pojo.DepartInfo;
import utils.JDBCUtils;

import java.sql.SQLException;
import java.util.List;

public class DepartInfoDaoImpl implements DepartInfoDao {

    @Override
    public List<DepartInfo> findDepartInfo(String d_id) throws SQLException {
        String sql ="SELECT * FROM departInfo WHERE d_id = ?";
        QueryRunner queryRunner = new QueryRunner(JDBCUtils.getDataSource());
        List<DepartInfo> list = queryRunner.query(sql,new BeanListHandler<DepartInfo>(DepartInfo.class),d_id);
        return  list;
    }

    @Override
    public DepartInfo findDepartStatus(String id) throws SQLException {
        String sql ="SELECT * FROM `departInfo` WHERE id = ?";
        QueryRunner queryRunner = new QueryRunner(JDBCUtils.getDataSource());
        DepartInfo departInf = queryRunner.query(sql,new BeanHandler<DepartInfo>(DepartInfo.class),id);
        return  departInf;
    }
}
